package com.zmh.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.zmh.entity.WebsiteEntity;


/** 
 * 查询全部网站基本信息
 * @author zhoumh
 * @version 创建时间：2018年7月15日 上午10:10:10 
 * @Description 
*/
@Mapper
public interface WebsiteMapper {
	@Select("SELECT id, uuid, name, url, detail, type, state, createtime, updatetime, description FROM website")
	List<WebsiteEntity> getAll();
	
	/**
	 * 根据网站名称查询网站信息
	 * @return: WebsiteEntity
	 * @author: zhoumh
	 * @version: 创建时间：2018年7月22日 下午10:12:06 
	 * @Description:
	 */
	@Select("SELECT id, uuid, name, url, detail, type, state, createtime, updatetime, description FROM website WHERE name = #{name}")
	WebsiteEntity getOneByName(String name);
	
	/**
	 * 根据书籍uuid查询书籍信息
	 * @return: WebsiteEntity
	 * @author: zhoumh
	 * @version: 创建时间：2018年7月22日 下午10:12:06 
	 * @Description:
	 */
	@Select("SELECT * FROM website WHERE uuid = #{uuid}")
	WebsiteEntity getOneByUuid(String uuid);


	@Insert("INSERT INTO website(uuid,name,url,detail,description) VALUES(uuid(),#{name}, #{url}, #{detail}, #{description})")
	int insert(WebsiteEntity website);

	@Update("UPDATE website SET name=#{name},url=#{url},detail=#{detail},description=#{description} WHERE uuid =#{uuid}")
	int update(WebsiteEntity website);

	@Delete("DELETE FROM website WHERE uuid =#{uuid}")
	int delete(String uuid);
}
